/*
  学习目标：props添加默认值
*/

import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class App extends Component {
  render() {
    return (
      <div>
        <Child title={<h1>123</h1>} />
        <Hello />
      </div>
    );
  }
}

// 2. 函数式组件结构设置默认值
function Hello({ count = 100 }) {
  return <h1>Hello - {count}</h1>;
}

Hello.propTypes = {
  count: PropTypes.number.isRequired,
};

class Child extends React.Component {
  render() {
    return <div>{this.props.name}</div>;
  }
}

Child.propTypes = {
  name: PropTypes.number.isRequired,
  title: PropTypes.element,
};

// 1. 🔔组件名.defaultProps = { 属性名: 值}
Child.defaultProps = {
  name: 30,
};
